﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Microsoft.VisualStudio.CommandBars;
using Rhino.Mocks;
using System.Reflection;
using EnvDTE80;
using EnvDTE;
using TSVNAddin.Core;

namespace TSVNAddin.VS.Test
{
	[TestFixture]
	public class MenuBuilderFixture
	{
		[Test]
		public void SetupCommands()
		{
			CommandBarPopup barPopup = MockRepository.GenerateStub<CommandBarPopup>();

			CommandType[] commandTypes = new CommandType[]
            {
                CommandType.AboutTortoiseSVNAddin
            };

			MenuTortoriseAdapter commandAdder = MockRepository.GenerateMock<MenuTortoriseAdapter>((DTE2)null, (AddIn)null);
			ResourceProxy resourceProxy = MockRepository.GenerateMock<ResourceProxy>();

			foreach (CommandType commandType in commandTypes)
			{
				string descr = "descr_" + commandType.ToString();
				resourceProxy.Expect(x => x.GetString(commandType.ToString())).Return(descr);
				commandAdder.Expect(x => x.AddCommand(commandType.ToString(), descr, (int)commandType, barPopup));
			}

			MenuBarAdapter commandBarAdder = MockRepository.GenerateMock<MenuBarAdapter>((DTE2)null);
			commandBarAdder.Expect(x => x.AddTortoiseCommandBar()).Return(barPopup);

			MenuBuilder menuBuilder = new MenuBuilder(commandBarAdder, commandAdder, resourceProxy);
			menuBuilder.SetupMenu();

			commandBarAdder.VerifyAllExpectations();
			commandAdder.VerifyAllExpectations();
		}
	}
}
